package be.ac.ua.pats.thesisrobotica.robot.RR.sensors;

//~--- non-JDK imports --------------------------------------------------------

import be.ac.ua.pats.thesisrobotica.robot.RR.Reflective;
import be.ac.ua.pats.thesisrobotica.robot.communication.Connection;
import be.ac.ua.pats.thesisrobotica.robot.constants.RobotConstants;
import be.ac.ua.pats.thesisrobotica.robot.exceptions.InitializationException;

/**
 * @author Jimmy
 */
public class Battery extends Sensor implements Reflective {

    public Battery() {
        this(null);
    }

    public Battery(Connection connection) {
       super(connection);

        type        = RobotConstants.Types.TOUCHSENSOR;
        initialized = true;
    }

    /**
     * @return The current sensor reading
     */
    @Override
    public int getRealValue() throws InitializationException {
        if (initialized) {
            return lejos.nxt.Battery.getVoltageMilliVolt();
        } else {
            throw new InitializationException(this.id);
        }
    }

    @Override
    public String getValue() throws InitializationException {
                if (initialized) {
            return String.valueOf(lejos.nxt.Battery.getVoltageMilliVolt());
        } else {
            throw new InitializationException(this.id);
        }
    }
}